<template>
	<view class="home">
		<view class="flex align-center padding-20 radius-10 bg-ff margin-bottom-20" v-for="(item,index) in list" :key="index">
			<image :src="item.goods.image" mode="" class="listimg"></image>
			<view class="flex-one margin-left-30">
				<view class="text-cut-two text-30 height-80 line-40">{{item.goods.title}}</view>
				<view class="margin-top-45 flex align-center">
					<view class="text-40 flex-one" style="color: #EF5205;">￥{{item.goods.price}}</view>
					<view class="collbtn" @click="getFllow(item.goods_id)">取消收藏</view>
				</view>
			</view>
		</view>
		<view class="text-28 text-99 text-center" v-if="list.length==0">暂无数据~</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: []
			}
		},
		onShow() {
			this.getList()
		},
		methods: {
			getList() {
				this.$u.post('api/user/GetCollection', {}).then(res => {
					if (res.code == 1) {
						this.list = res.data.data
					}
				})
			},
			getFllow(id){
				this.$u.post('api/wanlshop/product/follow', {
					id:id
				}).then(res => {
					if (res.code == 1) {
						this.getList()
					}
				})
			}
		}
	}
</script>

<style>
	@import url(@/components/common.css);
	.home {
		width: 100%;
		min-height: 100vh;
		background: #f6f6f6;
		padding: 30rpx;
	}
	.listimg{
		width: 186rpx;
		height: 186rpx;
	}
	.collbtn{
		width: 130rpx;
		height: 46rpx;
		background: linear-gradient( 90deg, #5F6ACC 0%, #6E99DE 100%);
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		color: #FFFFFF;
		line-height: 46rpx;
		text-align: center;
	}
</style>